package com.quarter.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.quarter.dao.CompanyListDao;
import com.quarter.db.DBConnect;

public class CompanyListDaoImpl implements CompanyListDao{
	public ArrayList<String> ListAllCompany() throws Exception{
		ArrayList<String> list = new ArrayList<String>();
        String sql="SELECT * FROM company";
        Connection conn=null;
        PreparedStatement preStmt=null;
        ResultSet rs=null;
        try{
            conn=DBConnect.getCon();
            preStmt=conn.prepareStatement(sql);
            rs=preStmt.executeQuery();
            while(rs.next()){
              	
                list.add(rs.getString("CNAME"));
            }
        }finally{
            if(rs!=null) rs.close();
            if(preStmt!=null) preStmt.close();
            if(conn!=null)  conn.close();
        }
        
        return list;
	}
	
	public ArrayList<String> ListAllComInfo() throws Exception{
		ArrayList<String> list = new ArrayList<String>();
        String sql="SELECT * FROM company";
        Connection conn=null;
        PreparedStatement preStmt=null;
        ResultSet rs=null;
        try{
            conn=DBConnect.getCon();
            preStmt=conn.prepareStatement(sql);
            rs=preStmt.executeQuery();
            while(rs.next()){
              	
                list.add(rs.getString("INFORMATION"));
            }
        }finally{
            if(rs!=null) rs.close();
            if(preStmt!=null) preStmt.close();
            if(conn!=null)  conn.close();
        }
        
        return list;
	}
}
